# This makefile can work with both GCC and CrayCC. Here are the steps you need to perform to compile with
#
# GCC:
#  $ module swap PrgEnv-<whatever module is loaded currently> PrgEnv-gnu
#  [Make sure "include Makefile.gcc" is uncommented and "include Makefile.craycc" is commented below
#
# CrayCC
#  $ module swap PrgEnv-<whatever module is loaded currently> PrgEnv-cray
#  [Make sure "include Makefile.craycc" is uncommented and "include Makefile.gnu" is commented below
# 

CC = cc


# OPT flags come from Makefile.gcc or Makefile.craycc.

# include Makefile.gcc
include Makefile.craycc


targets += benchmark-naive 
targets += benchmark-blocked 
targets += benchmark-blas 
targets += benchmark-naiveOpt1 
targets += benchmark-blockedOpt1 
targets += benchmark-naiveSIMD
targets += benchmark-mor
targets += benchmark-mor-blocked


objects += benchmark.o
objects += benchmark-simple.o 
objects += dgemm-naive.o 
objects += dgemm-blocked.o 
objects += dgemm-blas.o 
objects += dgemm-naiveOpt1.o 
objects += dgemm-blockedOpt1.o 
objects += dgemm-naiveSIMD.o
objects += dgemm-naive-mor.o
objects += dgemm-blocked-mor.o

.PHONY : default
default : all

.PHONY : all
all : clean $(targets)

# TA provided implementations
benchmark-naive : benchmark.o dgemm-naive.o 
	$(CC) -o $@ $^ $(LDLIBS)
benchmark-blocked : benchmark.o dgemm-blocked.o
	$(CC) -o $@ $^ $(LDLIBS)
benchmark-blas : benchmark.o dgemm-blas.o
	$(CC) -o $@ $^ $(LDLIBS)

# Sarah's stuff
benchmark-naiveOpt1 : benchmark.o dgemm-naiveOpt1.o
	$(CC) -o $@ $^ $(LDLIBS)
benchmark-blockedOpt1 : benchmark.o dgemm-blockedOpt1.o
	$(CC) -o $@ $^ $(LDLIBS)
benchmark-naiveSIMD : benchmark.o dgemm-naiveSIMD.o
	$(CC) -o $@ $^ $(LDLIBS)

# Nitesh's stuff
benchmark-mor: benchmark.o dgemm-naive-mor.o
	$(CC) -o $@ $^ $(LDLIBS)
benchmark-mor-blocked: benchmark.o dgemm-blocked-mor.o
	$(CC) -o $@ $^ $(LDLIBS)


%.o : %.c
	$(CC) -c $(CFLAGS) $<

.PHONY : clean
clean:
	rm -f $(targets) $(objects) *+pat *.apa graph.png
